package com.backend.appointmanage.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.backend.common.annotation.Log;
import com.backend.common.core.controller.BaseController;
import com.backend.common.core.domain.AjaxResult;
import com.backend.common.enums.BusinessType;
import com.backend.appointmanage.domain.ViewingAppointmentManageView;
import com.backend.appointmanage.service.IViewingAppointmentManageViewService;
import com.backend.common.utils.poi.ExcelUtil;
import com.backend.common.core.page.TableDataInfo;

/**
 * 看房预约管理Controller
 * 
 * @author fusi
 * @date 2024-10-12
 */
@RestController
@RequestMapping("/appointmanage/appointmanage")
public class ViewingAppointmentManageViewController extends BaseController
{
    @Autowired
    private IViewingAppointmentManageViewService viewingAppointmentManageViewService;

    /**
     * 查询看房预约管理列表
     */
    @PreAuthorize("@ss.hasPermi('appointmanage:appointmanage:list')")
    @GetMapping("/list")
    public TableDataInfo list(ViewingAppointmentManageView viewingAppointmentManageView)
    {
        startPage();
        List<ViewingAppointmentManageView> list = viewingAppointmentManageViewService.selectViewingAppointmentManageViewList(viewingAppointmentManageView);
        return getDataTable(list);
    }

    /**
     * 导出看房预约管理列表
     */
    @PreAuthorize("@ss.hasPermi('appointmanage:appointmanage:export')")
    @Log(title = "看房预约管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ViewingAppointmentManageView viewingAppointmentManageView)
    {
        List<ViewingAppointmentManageView> list = viewingAppointmentManageViewService.selectViewingAppointmentManageViewList(viewingAppointmentManageView);
        ExcelUtil<ViewingAppointmentManageView> util = new ExcelUtil<ViewingAppointmentManageView>(ViewingAppointmentManageView.class);
        util.exportExcel(response, list, "看房预约管理数据");
    }

    /**
     * 获取看房预约管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('appointmanage:appointmanage:query')")
    @GetMapping(value = "/{viewingAppointmentId}")
    public AjaxResult getInfo(@PathVariable("viewingAppointmentId") Long viewingAppointmentId)
    {
        return success(viewingAppointmentManageViewService.selectViewingAppointmentManageViewByViewingAppointmentId(viewingAppointmentId));
    }
    @PreAuthorize("@ss.hasPermi('appointmanage:appointmanage:query')")
    @GetMapping(value = "/mobileUser/{mobileUserId}")
    public AjaxResult getMobileUser(@PathVariable Long mobileUserId){
        return success(viewingAppointmentManageViewService.selectMobileUserByMobileUserId(mobileUserId));
    }
    @PreAuthorize("@ss.hasPermi('appointmanage:appointmanage:query')")
    @GetMapping(value = "/room/{roomId}")
    public AjaxResult getRoom(@PathVariable Long roomId){
        return success(viewingAppointmentManageViewService.selectRoomByRoomId(roomId));
    }
    /**
     * 新增看房预约管理
     */
    @PreAuthorize("@ss.hasPermi('appointmanage:appointmanage:add')")
    @Log(title = "看房预约管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ViewingAppointmentManageView viewingAppointmentManageView)
    {
        return toAjax(viewingAppointmentManageViewService.insertViewingAppointmentManageView(viewingAppointmentManageView));
    }

    /**
     * 修改看房预约管理
     */
    @PreAuthorize("@ss.hasPermi('appointmanage:appointmanage:edit')")
    @Log(title = "看房预约管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ViewingAppointmentManageView viewingAppointmentManageView)
    {
        return toAjax(viewingAppointmentManageViewService.updateViewingAppointmentManageView(viewingAppointmentManageView));
    }

    /**
     * 删除看房预约管理
     */
    @PreAuthorize("@ss.hasPermi('appointmanage:appointmanage:remove')")
    @Log(title = "看房预约管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{viewingAppointmentIds}")
    public AjaxResult remove(@PathVariable Long[] viewingAppointmentIds)
    {
        return toAjax(viewingAppointmentManageViewService.deleteViewingAppointmentByViewingAppointmentIds(viewingAppointmentIds));
    }
}
